home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1996
/
MacHack 1996.toast
/
Hacks
/
Hacks ’95
/
Is Native
/
MyDrawString.c
< prev
next >
Wrap
Text File
|
1995-06-24
|
2KB
|
96 lines
//
// File: MyDrawString.c
// Project: IsNative.π
// Author: Glenn L. Austin
// Symantec Corporation
//
#include <Traps.h>
#include "IsNative.h"
extern Str255 sysSoftStr;
extern WindowPtr aboutWindow;
extern void* oldHideWindowTrap;
extern pascal void MyHideWindow(WindowPtr theWindow);
pascal void MyDrawString(StringPtr sp)
{
long oldA4 = SetA4World();
WindowPeek aWind;
Boolean resetFace = false;
Style oldFace;
if (EqualString(LMGetCurApName(), LMGetFinderName(), false, true))
{ // current application is the finder!
GetPort((GrafPtr*) &aWind); // get the current port (hopefully it's a window)
if ((375 < aWind->port.portRect.right) &&
(aWind->port.portRect.right < 380)) // should be 377 for About…
{
if (!aboutWindow)
{
aboutWindow = (WindowPtr) aWind;
oldHideWindowTrap = (void*) GetToolTrapAddress(_HideWindow);
SetToolTrapAddress((void*) MyHideWindow, _HideWindow);
StartAnimation();
}
if ((aWind->port.pnLoc.v > 83) && (aWind->port.pnLoc.h == 41))
{
// OK, I'm drawing process names, so check the process name against
// my internal table of processes which are native
MyAppInfo *info = FindAppInfo(sp);
if ((info && (info->flags & kIsNative)) ||
EqualString(sp, sysSoftStr, true, true))
{
Style newFace = (info->flags & kIsNative) ? italic : 0;
oldFace = aWind->port.txFace;
resetFace = true;
if (info->flags & kHas68K)
newFace |= bold | condense;
if (!newFace) // 68K w/native code
newFace = bold | condense;
TextFace(newFace);
}
}
}
}
(glob->oldDrwStrTrap)(sp);
if (resetFace)
aWind->port.txFace = oldFace;
RestoreA4World(oldA4);
}
MyAppInfo* FindAppInfo(StringPtr sp)
{
long numEnt = GetHandleSize((Handle) glob->appInfo) / sizeof(MyAppInfo);
MyAppInfo *info = *glob->appInfo;
while (numEnt--)
{
Byte* p = (Byte*) &sp[1];
Byte* q = (Byte*) &info->appName[1];
Byte l = sp[0];
if (q[0] >= l)
{
if (sp[sp[0]] == (Byte) '…')
--l; // don't check the ellipsis
while (l--)
if (*p++ != *q++)
break;
if ((char) l < 0) // strings match! (l is decremented one more time)
return(info);
}
++info;
}
return(nil);
}